package J.算法.排序;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class sort0401 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str ;
        while ((str=br.readLine())!= null){
            String[] strs = str.split(",");
            int[] nums = new int[strs.length];
            for (int i = 0;i< nums.length;i++){
                nums[i] = Integer.valueOf(strs[i]);
            }

            //bubbleSort(nums);
            //selectSort(nums);
            //insertSort(nums);
            //shellSort(nums);
            //quickSort(nums,0,nums.length-1);
            mergeSort(nums,0,nums.length-1);
            //  bucketSort(nums);
            //radixSort(nums);
            for (int num:nums){
                System.out.println(num);
            }
        }
    }

    public static void bubbleSort(int[] nums){

        int temp =0;
        boolean change = false;
        for (int i=0;i<nums.length;i++){
            for (int j = 0; j < nums.length-i-1; j++) {
                if (nums[j]>nums[j+1]){
                    change = true;
                    temp = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = temp;

                }

            }
            if (!change){
                break;
            }
        }
    }
    public static void selectSort(int[] nums){
        for (int i=0;i<nums.length;i++){

            int min = nums[i];
            for (int j = i+1; j < nums.length; j++) {

                if (nums[j] < min){
                    nums[i] = nums[j];
                    nums[j] = min;
                }

            }

        }
    }
    public static void insertSort(int[] nums){

        for (int i = 1; i < nums.length; i++) {
            for (int j = i; j < nums.length; j++) {
                int searchIndex = j-1;
                int insertVal = nums[j];

                while (searchIndex>=0 && nums[searchIndex]> insertVal){
                    nums[searchIndex+1] = nums[searchIndex];
                    searchIndex--;

                }
                nums[searchIndex+1] = insertVal;

            }
            
        }
    }

    public static void shellSort(int[] nums){

        for (int gap=nums.length/2;gap>0;gap /=2){
            for (int i = gap;i<nums.length;i+=gap){
                int searchIndex = i-gap;
                int insertVal = nums[i];

                while (searchIndex>=0 && nums[searchIndex] > insertVal){
                    nums[searchIndex+gap] = nums[searchIndex];
                    searchIndex -= gap;
                }
                nums[searchIndex+gap] = insertVal;
            }
        }

    }

    public static void quickSort(int[] nums,int start,int end){
         if (start < end){
             int left = start;
             int base = nums[left];
             int right = end;

             while (left < right){
                 while (left < right && nums[right]> base){
                     right--;
                 }
                 nums[left] = nums[right];

                 while (left < right && nums[left]<base){
                     left++;
                 }
                 nums[right] = nums[left];

             }
             nums[right] = base;

             quickSort(nums,start,left);
             quickSort(nums,left+1,right);



         }


    }

    public static void mergeSort(int[] nums,int start,int end){
        if (start<end){
            int mid = (start+end)/2;
            mergeSort(nums,start,mid);
            mergeSort(nums,mid+1,end);

            merge(nums,start,mid,end);
        }

    }
    public static void merge(int[] nums,int left,int mid,int right){
        int l= left;
        int r = mid+1;
        int[] temp = new int[right-left+1];
        int index =0;

        while (l <= mid && r <= right){
            if (nums[l]< nums[r]){
                temp[index++] = nums[l++];
            }else {
                temp[index++] = nums[r++];
            }
        }

        while (l<= mid){
            temp[index++] = nums[l++];
        }
        while (r<= right){
            temp[index++] = nums[r++];
        }

        for (int i = 0; i < index; i++) {
            nums[i+left] = temp[i];

        }
    }


}
